<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,IE=9,chrome=1"><meta name="generator" content="MATLAB R2020a"><title>基于MATLAB函数的16-QAM通信链路仿真</title><style type="text/css">.rtcContent { padding: 30px; } .S0 { margin: 3px 10px 5px 4px; padding: 0px; line-height: 28.8px; min-height: 0px; white-space: pre-wrap; color: rgb(213, 80, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 24px; font-weight: 400; text-align: center;  }
.S1 { margin: 15px 10px 5px 4px; padding: 0px; line-height: 28.8px; min-height: 0px; white-space: pre-wrap; color: rgb(213, 80, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 24px; font-weight: 400; text-align: center;  }
.S2 { margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;  }
.S3 { margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: rgb(60, 60, 60); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: 700; text-align: left;  }
.S4 { margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;  }
.S5 { margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;  }
.S6 { margin: 3px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: rgb(60, 60, 60); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: 700; text-align: left;  }
.S7 { margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;  }
.S8 { margin: 3px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: rgb(60, 60, 60); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 15px; font-weight: 700; text-align: left;  }
.CodeBlock { background-color: #F7F7F7; margin: 10px 0 10px 0;}
.S9 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 0px none rgb(0, 0, 0); border-radius: 4px 4px 0px 0px; padding: 6px 45px 0px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S10 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 0px none rgb(0, 0, 0); border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S11 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 0px; padding: 0px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S12 { color: rgb(64, 64, 64); padding: 10px 0px 6px 17px; background: rgb(255, 255, 255) none repeat scroll 0% 0% / auto padding-box border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; overflow-x: hidden; line-height: 17.234px;  }
.S13 { margin: 10px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: rgb(60, 60, 60); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 15px; font-weight: 700; text-align: left;  }
.S14 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 0px 0px 4px 4px; padding: 0px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S15 { margin: 15px 10px 5px 4px; padding: 0px; line-height: 28.8px; min-height: 0px; white-space: pre-wrap; color: rgb(213, 80, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 24px; font-weight: 400; text-align: left;  }
.embeddedOutputsErrorElement {min-height: 18px; max-height: 250px; overflow: auto;}
.embeddedOutputsErrorElement.inlineElement {}
.embeddedOutputsErrorElement.rightPaneElement {}
.embeddedOutputsWarningElement{min-height: 18px; max-height: 250px; overflow: auto;}
.embeddedOutputsWarningElement.inlineElement {}
.embeddedOutputsWarningElement.rightPaneElement {}
.diagnosticMessage-wrapper {font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 12px;}
.diagnosticMessage-wrapper.diagnosticMessage-warningType {color: rgb(255,100,0);}
.diagnosticMessage-wrapper.diagnosticMessage-warningType a {color: rgb(255,100,0); text-decoration: underline;}
.diagnosticMessage-wrapper.diagnosticMessage-errorType {color: rgb(230,0,0);}
.diagnosticMessage-wrapper.diagnosticMessage-errorType a {color: rgb(230,0,0); text-decoration: underline;}
.diagnosticMessage-wrapper .diagnosticMessage-messagePart,.diagnosticMessage-wrapper .diagnosticMessage-causePart {white-space: pre-wrap;}
.diagnosticMessage-wrapper .diagnosticMessage-stackPart {white-space: pre;}
.embeddedOutputsTextElement,.embeddedOutputsVariableStringElement {white-space: pre; word-wrap: initial; min-height: 18px; max-height: 250px; overflow: auto;}
.textElement,.rtcDataTipElement .textElement {padding-top: 3px;}
.embeddedOutputsTextElement.inlineElement,.embeddedOutputsVariableStringElement.inlineElement {}
.inlineElement .textElement {}
.embeddedOutputsTextElement.rightPaneElement,.embeddedOutputsVariableStringElement.rightPaneElement {min-height: 16px;}
.rightPaneElement .textElement {padding-top: 2px; padding-left: 9px;}
.S16 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 0px none rgb(0, 0, 0); border-radius: 0px; padding: 6px 45px 0px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S17 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 0px; padding: 6px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.variableValue { width: 100% !important; }
.embeddedOutputsMatrixElement,.eoOutputWrapper .matrixElement {min-height: 18px; box-sizing: border-box;}
.embeddedOutputsMatrixElement .matrixElement,.eoOutputWrapper .matrixElement,.rtcDataTipElement .matrixElement {position: relative;}
.matrixElement .variableValue,.rtcDataTipElement .matrixElement .variableValue {white-space: pre; display: inline-block; vertical-align: top; overflow: hidden;}
.embeddedOutputsMatrixElement.inlineElement {}
.embeddedOutputsMatrixElement.inlineElement .topHeaderWrapper {display: none;}
.embeddedOutputsMatrixElement.inlineElement .veTable .body {padding-top: 0 !important; max-height: 100px;}
.inlineElement .matrixElement {max-height: 300px;}
.embeddedOutputsMatrixElement.rightPaneElement {}
.rightPaneElement .matrixElement,.rtcDataTipElement .matrixElement {overflow: hidden; padding-left: 9px;}
.rightPaneElement .matrixElement {margin-bottom: -1px;}
.embeddedOutputsMatrixElement .matrixElement .valueContainer,.eoOutputWrapper .matrixElement .valueContainer,.rtcDataTipElement .matrixElement .valueContainer {white-space: nowrap; margin-bottom: 3px;}
.embeddedOutputsMatrixElement .matrixElement .valueContainer .horizontalEllipsis.hide,.embeddedOutputsMatrixElement .matrixElement .verticalEllipsis.hide,.eoOutputWrapper .matrixElement .valueContainer .horizontalEllipsis.hide,.eoOutputWrapper .matrixElement .verticalEllipsis.hide,.rtcDataTipElement .matrixElement .valueContainer .horizontalEllipsis.hide,.rtcDataTipElement .matrixElement .verticalEllipsis.hide {display: none;}
.embeddedOutputsVariableMatrixElement .matrixElement .valueContainer.hideEllipses .verticalEllipsis, .embeddedOutputsVariableMatrixElement .matrixElement .valueContainer.hideEllipses .horizontalEllipsis {display:none;}
.embeddedOutputsMatrixElement .matrixElement .valueContainer .horizontalEllipsis,.eoOutputWrapper .matrixElement .valueContainer .horizontalEllipsis {margin-bottom: -3px;}
.eoOutputWrapper .embeddedOutputsVariableMatrixElement .matrixElement .valueContainer {cursor: default !important;}
.embeddedOutputsVariableElement {white-space: pre-wrap; word-wrap: break-word; min-height: 18px; max-height: 250px; overflow: auto;}
.variableElement {}
.embeddedOutputsVariableElement.inlineElement {}
.inlineElement .variableElement {}
.embeddedOutputsVariableElement.rightPaneElement {min-height: 16px;}
.rightPaneElement .variableElement {padding-top: 2px; padding-left: 9px;}
.variableNameElement {margin-bottom: 3px; display: inline-block;}
.matrixElement .horizontalEllipsis,.rtcDataTipElement .matrixElement .horizontalEllipsis {display: inline-block; margin-top: 3px; width: 30px; height: 12px; background-repeat: no-repeat; background-image: url("");}
.matrixElement .verticalEllipsis,.textElement .verticalEllipsis,.rtcDataTipElement .matrixElement .verticalEllipsis,.rtcDataTipElement .textElement .verticalEllipsis {margin-left: 35px; width: 12px; height: 30px; background-repeat: no-repeat; background-image: url("");}</style></head><body><div class = rtcContent><h1  class = 'S0'><span>基于MATLAB函数的16-QAM通信链路仿真</span></h1><h1  class = 'S1'><span>实验报告</span></h1><div  class = 'S2'><span>丁天威 1850700</span></div><h2  class = 'S3'><span style=' font-family: monospace;'>一、实验目的</span></h2><ol  class = 'S4'><li  class = 'S5'><span style=' font-family: monospace;'>学习和掌握利用MATLAB</span><span style=' font-family: monospace;'>函数搭建基本的通信系统仿真链路。</span></li><li  class = 'S5'><span style=' font-family: monospace;'>研究升余弦滤波器和卷积纠错编码对系统链路性能的影响。</span></li></ol><h2  class = 'S3'><span style=' font-family: monospace;'>二、实验内容</span></h2><ol  class = 'S4'><li  class = 'S5'><span style=' font-family: monospace;'>仿真16</span><span style=' font-family: monospace;'>-</span><span style=' font-family: monospace;'>QAM</span><span style=' font-family: monospace;'>调制的基带数字通信系统通过高斯白噪声信道下的基本性能；</span></li><li  class = 'S5'><span style=' font-family: monospace;'>对比加入脉冲成型滤波器后链路的性能；</span></li><li  class = 'S5'><span style=' font-family: monospace;'>对比加入脉冲成型滤波器和卷积码进行纠错后链路的性能。</span></li></ol><h2  class = 'S3'><span style=' font-family: monospace;'>三、实验步骤</span></h2><h3  class = 'S6'><span style=' font-family: monospace;'>1、仿真16-QAM调制的基带数字通信系统通过高斯白噪声信道下的基本性能</span></h3><div  class = 'S7'><span style=' font-family: monospace;'>1) 仿真框图</span></div><div  class = 'S7'><span style=' font-family: monospace;'></span></div><div  class = 'S2'><img class = "imageNode" src = "" alt = "未命名文件(22).png" style = "vertical-align: baseline"></img></div><div  class = 'S2'><span style=' font-family: monospace;'>16-QAM调制的基带数字通信系统通过高斯白噪声信道</span></div><div  class = 'S7'><span style=' font-family: monospace;'></span></div><div  class = 'S7'><span style=' font-family: monospace;'>2) 参数设置</span></div><ol  class = 'S4'><li  class = 'S5'><span style=' font-family: monospace;'>QAM 16</span></li><li  class = 'S5'><span style=' font-family: monospace;'>30000bits</span></li><li  class = 'S5'><span style=' font-family: monospace;'>10dB高斯白噪声</span></li></ol><div  class = 'S7'><span style=' font-family: monospace;'>3) 基本步骤</span></div><h4  class = 'S8'><span>生成信号</span></h4><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>M=16;</span><span class="warning_squiggle_rte430069889 warningHighlight430069889">;</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>k=log2(M);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>n=30000;</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>sps=1;</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>rng </span><span style="color: rgb(160, 32, 240);">default</span><span>;</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>dataIn=randi([0,1],n,1);  </span><span style="color: rgb(60, 118, 61);">% 0或1 取整数  </span></span></div></div><div class="inlineWrapper"><div  class = 'S10'></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>stem(dataIn(1:40),</span><span style="color: rgb(160, 32, 240);">'filled'</span><span>);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>title(</span><span style="color: rgb(160, 32, 240);">'random bits '</span><span>);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>xlabel(</span><span style="color: rgb(160, 32, 240);">'bit Index'</span><span>);</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: pre;"><span>ylabel(</span><span style="color: rgb(160, 32, 240);">'binary value'</span><span>);</span></span></div><div  class = 'S12'><div class="inlineElement eoOutputWrapper embeddedOutputsFigure" uid="3939C5EC" contenteditable="false" data-testid="output_0" style="width: 1129px;"><div class="figureElement" style="cursor: default;"><div class="figureContainingNode" style="width: 420px; max-width: 100%; display: inline-block;"><div class="GraphicsView" data-dojo-attach-point="graphicsViewNode,backgroundColorNode" id="uniqName_162_96" widgetid="uniqName_162_96" style="width: 100%; height: auto;"><img class="ImageView figureImage" data-dojo-attach-point="imageViewNode" draggable="false" ondragstart="return false;" id="uniqName_162_98" widgetid="uniqName_162_98" src="" style="width: 100%; height: auto;"></div></div></div></div></div></div></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: pre;"><span>dataMatrix=reshape(dataIn,length(dataIn)/k,k);    </span><span style="color: rgb(60, 118, 61);">%由于16QAM可以容纳16个信息，转换成二进制即4位</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>dataSymbolsIn=bi2de(dataMatrix);  </span><span style="color: rgb(60, 118, 61);">% 二进制转十进制 （变成symbol）</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>figure;</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>stem(dataSymbolsIn(1:10));</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>title(</span><span style="color: rgb(160, 32, 240);">'random symbols'</span><span>);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>xlabel(</span><span style="color: rgb(160, 32, 240);">'symbol index'</span><span>);</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: pre;"><span>ylabel(</span><span style="color: rgb(160, 32, 240);">'Inter Value'</span><span>);</span></span></div><div  class = 'S12'><div class="inlineElement eoOutputWrapper embeddedOutputsFigure" uid="9F383ACE" contenteditable="false" data-testid="output_1" style="width: 1129px;"><div class="figureElement" style="cursor: default;"><div class="figureContainingNode" style="width: 560px; max-width: 100%; display: inline-block;"><div class="GraphicsView" data-dojo-attach-point="graphicsViewNode,backgroundColorNode" id="uniqName_162_99" widgetid="uniqName_162_99" style="width: 100%; height: auto;"><img class="ImageView figureImage" data-dojo-attach-point="imageViewNode" draggable="false" ondragstart="return false;" id="uniqName_162_102" widgetid="uniqName_162_102" src="" style="width: 100%; height: auto;"></div></div></div></div></div></div></div><h4  class = 'S13'><span>编码</span></h4><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>dataMod = qammod(dataSymbolsIn,M,</span><span style="color: rgb(160, 32, 240);">'bin'</span><span>); </span><span style="color: rgb(60, 118, 61);">% 二进制编码</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>dataModG = qammod(dataSymbolsIn,M); </span><span style="color: rgb(60, 118, 61);">% 格雷码</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'></div></div><div class="inlineWrapper"><div  class = 'S14'></div></div></div><h4  class = 'S13'><span>加入噪声</span></h4><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: pre;"><span>EbNo = 10;</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>snr = EbNo+10*log10(k)-10*log10(sps);   </span><span style="color: rgb(60, 118, 61);">%10dB 噪声强度，信号强度 为信息熵转db，二者相加</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>receivedSignal = awgn(dataMod,snr,</span><span style="color: rgb(160, 32, 240);">'measured'</span><span>);</span></span></div></div><div class="inlineWrapper"><div  class = 'S14'><span style="white-space: pre;"><span>receivedSignalG = awgn(dataModG,snr,</span><span style="color: rgb(160, 32, 240);">'measured'</span><span>);</span></span></div></div></div><h4  class = 'S13'><span>画星图</span></h4><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>sPlotFig = scatterplot(receivedSignal,1,0,</span><span style="color: rgb(160, 32, 240);">'g.'</span><span>);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>hold </span><span style="color: rgb(160, 32, 240);">on</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: pre;"><span>scatterplot(dataMod,1,0,</span><span style="color: rgb(160, 32, 240);">'k*'</span><span>,sPlotFig)</span></span></div><div  class = 'S12'><div class="inlineElement eoOutputWrapper embeddedOutputsFigure" uid="4BB6FDB6" contenteditable="false" data-testid="output_2" style="width: 1129px;"><div class="figureElement"><div class="figureContainingNode" style="width: 420px; max-width: 100%; display: inline-block;"><div class="GraphicsView" data-dojo-attach-point="graphicsViewNode,backgroundColorNode" id="uniqName_162_100" widgetid="uniqName_162_100" style="width: 100%; height: auto;"><img class="ImageView figureImage" data-dojo-attach-point="imageViewNode" draggable="false" ondragstart="return false;" id="uniqName_162_104" widgetid="uniqName_162_104" src="" style="width: 100%; height: auto;"></div></div></div></div></div></div></div><h1  class = 'S15'><span></span></h1><h4  class = 'S8'><span>解码</span></h4><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>dataSymbolsOut = qamdemod(receivedSignal,M,</span><span style="color: rgb(160, 32, 240);">'bin'</span><span>);</span></span></div></div><div class="inlineWrapper"><div  class = 'S14'><span style="white-space: pre;"><span>dataSymbolsOutG = qamdemod(receivedSignalG,M);</span></span></div></div></div><h4  class = 'S13'><span>转换</span></h4><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span style="color: rgb(60, 118, 61);">% 这里是为了使用bitter 转10进制到2进制</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>dataOutMatrix = de2bi(dataSymbolsOut,k);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>dataOut = dataOutMatrix(:); </span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>dataOutMatrixG = de2bi(dataSymbolsOutG,k);</span></span></div></div><div class="inlineWrapper"><div  class = 'S14'><span style="white-space: pre;"><span>dataOutG = dataOutMatrixG(:);</span></span></div></div></div><h4  class = 'S13'><span>计算误比特率</span></h4><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'></div></div><div class="inlineWrapper"><div  class = 'S10'></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>[numErrors,ber] = biterr(dataIn,dataOut);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>fprintf(</span><span style="color: rgb(160, 32, 240);">'\nThe binary coding bit error rate is %5.2e, based on %d errors.\n'</span><span>, </span><span style="color: rgb(0, 0, 255);">...</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: pre;"><span>    ber,numErrors)</span></span></div><div  class = 'S12'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="7400C4B9" data-scroll-top="null" data-scroll-left="null" contenteditable="false" data-testid="output_3" data-width="1099" data-height="18" data-hashorizontaloverflow="false" style="width: 1129px; max-height: 261px;"><div class="textElement">The binary coding bit error rate is 2.40e-03, based on 72 errors.</div></div></div></div><div class="inlineWrapper"><div  class = 'S16'></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>[numErrorsG,berG] = biterr(dataIn,dataOutG);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>fprintf(</span><span style="color: rgb(160, 32, 240);">'\nThe Gray coding bit error rate is %5.2e, based on %d errors.\n'</span><span>, </span><span style="color: rgb(0, 0, 255);">...</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: pre;"><span>    berG,numErrorsG)</span></span></div><div  class = 'S12'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="EAB85D49" data-scroll-top="null" data-scroll-left="null" contenteditable="false" data-testid="output_4" style="width: 1129px; max-height: 261px;" data-width="1099" data-height="18" data-hashorizontaloverflow="false"><div class="textElement">The Gray coding bit error rate is 1.33e-03, based on 40 errors.</div></div></div></div></div><h4  class = 'S13'><span>画星图</span></h4><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>M = 16; </span><span style="color: rgb(60, 118, 61);">% Modulation order</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>x = (0:15); </span><span style="color: rgb(60, 118, 61);">% Integer input</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>symbin = qammod(x,M,</span><span style="color: rgb(160, 32, 240);">'bin'</span><span>); </span><span style="color: rgb(60, 118, 61);">% 16-QAM output (natural-coded binary)</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>symgray = qammod(x,M,</span><span style="color: rgb(160, 32, 240);">'gray'</span><span>); </span><span style="color: rgb(60, 118, 61);">% 16-QAM output (Gray-coded)</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>scatterplot(symgray,1,0,</span><span style="color: rgb(160, 32, 240);">'b*'</span><span>);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span style="color: rgb(0, 0, 255);">for </span><span>k = 1:M</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>    text(real(symgray(k)) - 0.0,imag(symgray(k)) + 0.3,</span><span style="color: rgb(0, 0, 255);">...</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>        dec2base(x(k),2,4));</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>     text(real(symgray(k)) - 0.5,imag(symgray(k)) + 0.3,</span><span style="color: rgb(0, 0, 255);">...</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>         num2str(x(k)));</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>    </span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>    text(real(symbin(k)) - 0.0,imag(symbin(k)) - 0.3,</span><span style="color: rgb(0, 0, 255);">...</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>        dec2base(x(k),2,4),</span><span style="color: rgb(160, 32, 240);">'Color'</span><span>,[1 0 0]);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>    text(real(symbin(k)) - 0.5,imag(symbin(k)) - 0.3,</span><span style="color: rgb(0, 0, 255);">...</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>        num2str(x(k)),</span><span style="color: rgb(160, 32, 240);">'Color'</span><span>,[1 0 0]);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span style="color: rgb(0, 0, 255);">end</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>title(</span><span style="color: rgb(160, 32, 240);">'16-QAM Symbol Mapping'</span><span>)</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: pre;"><span>axis([-4 4 -4 4])</span></span></div><div  class = 'S12'><div class="inlineElement eoOutputWrapper embeddedOutputsFigure" uid="83A273BE" contenteditable="false" data-testid="output_5" style="width: 1129px;"><div class="figureElement"><div class="figureContainingNode" style="width: 420px; max-width: 100%; display: inline-block;"><div class="GraphicsView" data-dojo-attach-point="graphicsViewNode,backgroundColorNode" id="uniqName_162_105" widgetid="uniqName_162_105" style="width: 100%; height: auto;"><img class="ImageView figureImage" data-dojo-attach-point="imageViewNode" draggable="false" ondragstart="return false;" id="uniqName_162_107" widgetid="uniqName_162_107" src="" style="width: 100%; height: auto;"></div></div></div></div></div></div></div><h3  class = 'S6'><span>2、 </span><span style=' font-family: monospace;'>对比加入脉冲成型滤波器后链路的性能</span></h3><div  class = 'S7'><span style=' font-family: monospace;'>1) 仿真框图</span></div><div  class = 'S7'><span style=' font-family: monospace;'></span></div><div  class = 'S2'><img class = "imageNode" src = "" alt = "加入pulse.png" style = "vertical-align: baseline"></img></div><div  class = 'S2'><span style=' font-family: monospace;'>加入脉冲成型滤波器</span></div><div  class = 'S7'><span style=' font-family: monospace;'></span></div><div  class = 'S7'><span style=' font-family: monospace;'>2) 参数设置</span></div><ol  class = 'S4'><li  class = 'S5'><span style=' font-family: monospace;'>QAM 16</span></li><li  class = 'S5'><span style=' font-family: monospace;'>300000bits</span></li><li  class = 'S5'><span style=' font-family: monospace;'>10dB高斯白噪声</span></li><li  class = 'S5'><span style=' font-family: monospace;'>采样频率 4</span></li><li  class = 'S5'><span style=' font-family: monospace;'>4bit每个symbol</span></li></ol><div  class = 'S7'><span style=' font-family: monospace;'>3) 基本步骤</span></div><h4  class = 'S13'><span>生成信号</span></h4><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>M = 16; </span><span style="color: rgb(60, 118, 61);">% Modulation order</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>k = log2(M); </span><span style="color: rgb(60, 118, 61);">% Number of bits per symbol</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>numBits = 300000; </span><span style="color: rgb(60, 118, 61);">% Number of bits to process</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>sps = 4; </span><span style="color: rgb(60, 118, 61);">% Number of samples per symbol (oversampling factor)</span></span></div></div><div class="inlineWrapper"><div  class = 'S14'></div></div></div><h4  class = 'S13'><span>创建RRC滤波器</span></h4><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>filtlen = 10; </span><span style="color: rgb(60, 118, 61);">% Filter length in symbols</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>rolloff = 0.25; </span><span style="color: rgb(60, 118, 61);">% Filter rolloff factor</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>rrcFilter = rcosdesign(rolloff,filtlen,sps);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: pre;"><span>fvtool(rrcFilter,</span><span style="color: rgb(160, 32, 240);">'Analysis'</span><span>,</span><span style="color: rgb(160, 32, 240);">'Impulse'</span><span>);</span></span></div><div  class = 'S12'><div class="inlineElement eoOutputWrapper embeddedOutputsFigure" uid="8DE45E12" data-scroll-top="null" data-scroll-left="null" contenteditable="false" data-testid="output_6" style="width: 1129px;"><div class="figureElement"><img class="figureImage figureContainingNode" src="" style="width: 1278px;"></div></div></div></div></div><h4  class = 'S8'><span>计算系统BER</span></h4><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: pre;"><span>rng </span><span style="color: rgb(160, 32, 240);">default</span><span>; </span><span style="color: rgb(60, 118, 61);">% Use default random number generator</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>dataIn = randi([0 1],numBits,1); </span><span style="color: rgb(60, 118, 61);">% Generate vector of binary data</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>dataInMatrix = reshape(dataIn,length(dataIn)/k,k); </span><span style="color: rgb(60, 118, 61);">% Reshape data into binary 4-tuples</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>dataSymbolsIn = bi2de(dataInMatrix); </span><span style="color: rgb(60, 118, 61);">% Convert to integers</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>dataMod = qammod(dataSymbolsIn,M);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>txFiltSignal = upfirdn(dataMod,rrcFilter,sps,1);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>EbNo = 10;</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>snr = EbNo + 10*log10(k) - 10*log10(sps);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>rxSignal = awgn(txFiltSignal,snr,</span><span style="color: rgb(160, 32, 240);">'measured'</span><span>);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>rxFiltSignal = upfirdn(rxSignal,rrcFilter,1,sps); </span><span style="color: rgb(60, 118, 61);">% Downsample and filter</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>rxFiltSignal = rxFiltSignal(filtlen + 1:end - filtlen); </span><span style="color: rgb(60, 118, 61);">% Account for delay</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>dataSymbolsOut = qamdemod(rxFiltSignal,M);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>dataOutMatrix = de2bi(dataSymbolsOut,k);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>dataOut = dataOutMatrix(:); </span><span style="color: rgb(60, 118, 61);">% Return data in column vector</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>[numErrors,ber] = biterr(dataIn,dataOut);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>fprintf(</span><span style="color: rgb(160, 32, 240);">'\nFor an EbNo setting of %3.1f dB, the bit error rate is %5.2e, based on %d errors.\n'</span><span>, </span><span style="color: rgb(0, 0, 255);">...</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: pre;"><span>    EbNo,ber,numErrors)</span></span></div><div  class = 'S12'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="0B9274B3" data-scroll-top="null" data-scroll-left="null" contenteditable="false" data-testid="output_7" style="width: 1129px; max-height: 261px;" data-width="1099" data-height="18" data-hashorizontaloverflow="false"><div class="textElement">For an EbNo setting of 10.0 dB, the bit error rate is 1.83e-03, based on 550 errors.</div></div></div></div></div><h4  class = 'S8'><span>可视化滤波器效果</span></h4><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: pre;"><span>EbNo = 20;</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>snr = EbNo + 10*log10(k) - 10*log10(sps);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>rxSignal = awgn(txFiltSignal,snr,</span><span style="color: rgb(160, 32, 240);">'measured'</span><span>);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>rxFiltSignal = upfirdn(rxSignal,rrcFilter,1,sps); </span><span style="color: rgb(60, 118, 61);">% Downsample and filter</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>rxFiltSignal = rxFiltSignal(filtlen + 1:end - filtlen); </span><span style="color: rgb(60, 118, 61);">% Account for delay</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: pre;"><span>eyediagram(txFiltSignal(1:2000),sps*2);</span></span></div><div  class = 'S12'><div class="inlineElement eoOutputWrapper embeddedOutputsFigure" uid="3631B972" data-scroll-top="null" data-scroll-left="null" contenteditable="false" data-testid="output_8" style="width: 1129px;"><div class="figureElement"><img class="figureImage figureContainingNode" src="" style="width: 460px;"></div></div></div></div><div class="inlineWrapper outputs"><div  class = 'S17'><span style="white-space: pre;"><span>eyediagram(rxSignal(1:2000),sps*2);</span></span></div><div  class = 'S12'><div class="inlineElement eoOutputWrapper embeddedOutputsFigure" uid="8B8A424F" data-scroll-top="null" data-scroll-left="null" contenteditable="false" data-testid="output_9" style="width: 1129px;"><div class="figureElement"><img class="figureImage figureContainingNode" src="" style="width: 460px;"></div></div></div></div><div class="inlineWrapper outputs"><div  class = 'S17'><span style="white-space: pre;"><span>eyediagram(rxFiltSignal(1:2000),2);</span></span></div><div  class = 'S12'><div class="inlineElement eoOutputWrapper embeddedOutputsFigure" uid="B94F73CC" data-scroll-top="null" data-scroll-left="null" contenteditable="false" data-testid="output_10" style="width: 1129px;"><div class="figureElement"><img class="figureImage figureContainingNode" src="" style="width: 460px;"></div></div></div></div></div><h4  class = 'S8'><span>画星图</span></h4><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>scatplot = scatterplot(sqrt(sps)*</span><span style="color: rgb(0, 0, 255);">...</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>    rxSignal(1:sps*5e3),</span><span style="color: rgb(0, 0, 255);">...</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>    sps,0,</span><span style="color: rgb(160, 32, 240);">'g.'</span><span>);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>hold </span><span style="color: rgb(160, 32, 240);">on</span><span>;</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>scatterplot(rxFiltSignal(1:5e3),1,0,</span><span style="color: rgb(160, 32, 240);">'kx'</span><span>,scatplot);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>title(</span><span style="color: rgb(160, 32, 240);">'Received Signal, Before and After Filtering'</span><span>);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>legend(</span><span style="color: rgb(160, 32, 240);">'Before Filtering'</span><span>,</span><span style="color: rgb(160, 32, 240);">'After Filtering'</span><span>);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>axis([-5 5 -5 5]); </span><span style="color: rgb(60, 118, 61);">% Set axis ranges</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: pre;"><span>hold </span><span style="color: rgb(160, 32, 240);">off</span><span>;</span></span></div><div  class = 'S12'><div class="inlineElement eoOutputWrapper embeddedOutputsFigure" uid="426EDA16" contenteditable="false" data-testid="output_11" style="width: 1129px;"><div class="figureElement"><div class="figureContainingNode" style="width: 420px; max-width: 100%; display: inline-block;"><div class="GraphicsView" data-dojo-attach-point="graphicsViewNode,backgroundColorNode" id="uniqName_162_108" widgetid="uniqName_162_108" style="width: 100%; height: auto;"><img class="ImageView figureImage" data-dojo-attach-point="imageViewNode" draggable="false" ondragstart="return false;" id="uniqName_162_110" widgetid="uniqName_162_110" src="" style="width: 100%; height: auto;"></div></div></div></div></div></div></div><h3  class = 'S6'><span>3、对比加入脉冲成型滤波器和卷积码进行纠错后链路的性能</span></h3><div  class = 'S7'><span style=' font-family: monospace;'>1) 仿真框图</span></div><div  class = 'S7'><span style=' font-family: monospace;'></span></div><div  class = 'S2'><img class = "imageNode" src = "" width = "748" height = "66" alt = "" style = "vertical-align: baseline"></img></div><div  class = 'S2'><span style=' font-family: monospace;'>16-QAM调制的基带数字通信系统通过高斯白噪声信道</span></div><div  class = 'S7'><span style=' font-family: monospace;'></span></div><div  class = 'S7'><span style=' font-family: monospace;'>2) 参数设置</span></div><ol  class = 'S4'><li  class = 'S5'><span style=' font-family: monospace;'>QAM 16</span></li><li  class = 'S5'><span style=' font-family: monospace;'>30000bits</span></li><li  class = 'S5'><span style=' font-family: monospace;'>10dB高斯白噪声</span></li></ol><div  class = 'S7'><span style=' font-family: monospace;'>3) 基本步骤</span></div><h4  class = 'S13'><span>初始化</span></h4><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: pre;"><span>M = 16; </span><span style="color: rgb(60, 118, 61);">% Modulation order</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>k = log2(M); </span><span style="color: rgb(60, 118, 61);">% Number of bits per symbol</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>numBits = 1e6; </span><span style="color: rgb(60, 118, 61);">% Number of bits to process</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>sps = 4; </span><span style="color: rgb(60, 118, 61);">% Number of samples per symbol (oversampling factor)</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>filtlen = 10; </span><span style="color: rgb(60, 118, 61);">% Filter length in symbols</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>rolloff = 0.25; </span><span style="color: rgb(60, 118, 61);">% Filter rolloff factor</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>rng </span><span style="color: rgb(160, 32, 240);">default</span><span>;                     </span><span style="color: rgb(60, 118, 61);">% Use default random number generator</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>dataIn = randi([0 1],numBits,1); </span><span style="color: rgb(60, 118, 61);">% Generate vector of binary data</span></span></div></div><div class="inlineWrapper"><div  class = 'S14'></div></div></div><h4  class = 'S13'><span>进行卷积编码</span></h4><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: pre;"><span>constrlen = [5 4]; </span><span style="color: rgb(60, 118, 61);">% Code constraint length</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: pre;"><span>genpoly = [23 35 0; 0 5 13] </span><span style="color: rgb(60, 118, 61);">% Generator polynomials</span></span></div><div  class = 'S12'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableMatrixElement" uid="CB080190" contenteditable="false" data-testid="output_12" data-width="1099" style="width: 1129px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="matrixElement veSpecifier" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="veVariableName variableNameElement double" style="width: 1099px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="headerElementClickToInteract" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">genpoly = </span><span class="veVariableValueSummary veMetaSummary" style="white-space: normal; font-style: normal; color: rgb(179, 179, 179); font-size: 12px;">2×3</span></div></div><div class="valueContainer" data-layout="{&quot;columnWidth&quot;:40,&quot;totalColumns&quot;:3,&quot;totalRows&quot;:2,&quot;charsPerColumn&quot;:6}" style="white-space: nowrap; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="variableValue" style="width: 122px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">    23    35     0
     0     5    13
</div><div class="horizontalEllipsis hide" style="white-space: nowrap; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"></div><div class="verticalEllipsis hide" style="white-space: nowrap; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"></div></div></div></div></div></div><div class="inlineWrapper"><div  class = 'S16'><span style="white-space: pre;"><span>tPoly = poly2trellis(constrlen,genpoly);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>codeRate = 2/3;</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>dataEnc = convenc(dataIn,tPoly);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'></div></div><div class="inlineWrapper"><div  class = 'S14'></div></div></div><h4  class = 'S13'><span>调制</span></h4><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>dataEncMatrix = reshape(dataEnc, </span><span style="color: rgb(0, 0, 255);">...</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>    length(dataEnc)/k,k); </span><span style="color: rgb(60, 118, 61);">% Reshape data into binary 4-tuples</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>dataSymbolsIn = bi2de(dataEncMatrix); </span><span style="color: rgb(60, 118, 61);">% Convert to integers</span></span></div></div><div class="inlineWrapper"><div  class = 'S14'><span style="white-space: pre;"><span>dataMod = qammod(dataSymbolsIn,M);</span></span></div></div></div><h4  class = 'S13'><span>RRC(Root-Raising-Cosine Filter)滤波</span></h4><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: pre;"><span>rrcFilter = rcosdesign(rolloff,filtlen,sps);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>txSignal = upfirdn(dataMod,rrcFilter,sps,1);</span></span></div></div><div class="inlineWrapper"><div  class = 'S14'></div></div></div><h4  class = 'S13'><span>加入高斯噪声</span></h4><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: pre;"><span>EbNo = 10;</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>snr = EbNo+10*log10(k*codeRate)-10*log10(sps);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>rxSignal = awgn(txSignal,snr,</span><span style="color: rgb(160, 32, 240);">'measured'</span><span>);</span></span></div></div><div class="inlineWrapper"><div  class = 'S14'></div></div></div><h4  class = 'S13'><span>解调</span></h4><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: pre;"><span>rxFiltSignal = upfirdn(rxSignal,rrcFilter,1,sps); </span><span style="color: rgb(60, 118, 61);">% Downsample and filter</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>rxFiltSignal = rxFiltSignal(filtlen + 1:end - filtlen); </span><span style="color: rgb(60, 118, 61);">% Account for delay</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>dataSymbolsOut = qamdemod(rxFiltSignal,M);</span></span></div></div><div class="inlineWrapper"><div  class = 'S14'></div></div></div><h4  class = 'S13'><span>解码</span></h4><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: pre;"><span>dataOutMatrix = de2bi(dataSymbolsOut,k);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>codedDataOut = dataOutMatrix(:); </span><span style="color: rgb(60, 118, 61);">% Return data in column vector</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>traceBack = 16; </span><span style="color: rgb(60, 118, 61);">% Traceback length for decoding</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>numCodeWords = floor(length(codedDataOut)*2/3); </span><span style="color: rgb(60, 118, 61);">% Number of complete codewords</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>dataOut = vitdec(codedDataOut(1:numCodeWords*3/2), </span><span style="color: rgb(0, 0, 255);">...</span></span></div></div><div class="inlineWrapper"><div  class = 'S14'><span style="white-space: pre;"><span>           tPoly,traceBack,</span><span style="color: rgb(160, 32, 240);">'cont'</span><span>,</span><span style="color: rgb(160, 32, 240);">'hard'</span><span>); </span><span style="color: rgb(60, 118, 61);">% Decode data</span></span></div></div></div><h4  class = 'S13'><span>计算误比特率</span></h4><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: pre;"><span>decDelay = 2*traceBack; </span><span style="color: rgb(60, 118, 61);">% Decoder delay, in bits</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>[numErrors,ber] = </span><span style="color: rgb(0, 0, 255);">...</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>   biterr(dataIn(1:end - decDelay),dataOut(decDelay + 1:end));       </span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: pre;"><span>fprintf(</span><span style="color: rgb(160, 32, 240);">'\nThe bit error rate is %5.2e, based on %d errors.\n'</span><span>, </span><span style="color: rgb(0, 0, 255);">...</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: pre;"><span>    ber,numErrors)</span></span></div><div  class = 'S12'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="B30BC9AF" data-scroll-top="null" data-scroll-left="null" contenteditable="false" data-testid="output_13" style="width: 1129px; max-height: 261px;" data-width="1099" data-height="18" data-hashorizontaloverflow="false"><div class="textElement">The bit error rate is 1.00e-04, based on 100 errors.</div></div></div></div></div><h2  class = 'S3'><span>四、实验结果与分析</span></h2><div  class = 'S7'><span style=' font-family: monospace;'>    通过性能对比可以看出，升余弦滤波器可以有效减少</span><span style=' font-family: monospace;'>1</span><span style=' font-family: monospace;'>6-</span><span style=' font-family: monospace;'>QAM数字通信系统的误码率，改变编码方式也可以改进误码率。</span></div></div>
<br>
<!-- 
##### SOURCE BEGIN #####
%% 基于MATLAB函数的16-QAM通信链路仿真
%% 实验报告
% 丁天威 1850700
%% |一、实验目的|
%% 
% # |学习和掌握利用MATLAB函数搭建基本的通信系统仿真链路。|
% # |研究升余弦滤波器和卷积纠错编码对系统链路性能的影响。|
%% |二、实验内容|
%% 
% # |仿真16-QAM调制的基带数字通信系统通过高斯白噪声信道下的基本性能；|
% # |对比加入脉冲成型滤波器后链路的性能；|
% # |对比加入脉冲成型滤波器和卷积码进行纠错后链路的性能。|
%% |三、实验步骤|
% |1、仿真16-QAM调制的基带数字通信系统通过高斯白噪声信道下的基本性能|
% |1) 仿真框图|
% 
% 
% 
% 
% 
% |16-QAM调制的基带数字通信系统通过高斯白噪声信道|
% 
% 
% 
% |2) 参数设置|
%% 
% # |QAM 16|
% # |30000bits|
% # |10dB高斯白噪声|
%% 
% |3) 基本步骤|
% 生成信号


M=16;;
k=log2(M);
n=30000;
sps=1;

rng default;
dataIn=randi([0,1],n,1);  % 0或1 取整数  

stem(dataIn(1:40),'filled');
title('random bits ');
xlabel('bit Index');
ylabel('binary value');
%%
dataMatrix=reshape(dataIn,length(dataIn)/k,k);    %由于16QAM可以容纳16个信息，转换成二进制即4位
dataSymbolsIn=bi2de(dataMatrix);  % 二进制转十进制 （变成symbol）

figure;
stem(dataSymbolsIn(1:10));
title('random symbols');
xlabel('symbol index');
ylabel('Inter Value');
% 编码


dataMod = qammod(dataSymbolsIn,M,'bin'); % 二进制编码
dataModG = qammod(dataSymbolsIn,M); % 格雷码


% 加入噪声

EbNo = 10;
snr = EbNo+10*log10(k)-10*log10(sps);   %10dB 噪声强度，信号强度 为信息熵转db，二者相加

receivedSignal = awgn(dataMod,snr,'measured');
receivedSignalG = awgn(dataModG,snr,'measured');
% 画星图


sPlotFig = scatterplot(receivedSignal,1,0,'g.');
hold on
scatterplot(dataMod,1,0,'k*',sPlotFig)
%% 
% 解码


dataSymbolsOut = qamdemod(receivedSignal,M,'bin');
dataSymbolsOutG = qamdemod(receivedSignalG,M);
% 转换


% 这里是为了使用bitter 转10进制到2进制
dataOutMatrix = de2bi(dataSymbolsOut,k);
dataOut = dataOutMatrix(:); 
dataOutMatrixG = de2bi(dataSymbolsOutG,k);
dataOutG = dataOutMatrixG(:);
% 计算误比特率



[numErrors,ber] = biterr(dataIn,dataOut);
fprintf('\nThe binary coding bit error rate is %5.2e, based on %d errors.\n', ...
    ber,numErrors)

[numErrorsG,berG] = biterr(dataIn,dataOutG);
fprintf('\nThe Gray coding bit error rate is %5.2e, based on %d errors.\n', ...
    berG,numErrorsG)
% 画星图


M = 16; % Modulation order
x = (0:15); % Integer input
symbin = qammod(x,M,'bin'); % 16-QAM output (natural-coded binary)
symgray = qammod(x,M,'gray'); % 16-QAM output (Gray-coded)
scatterplot(symgray,1,0,'b*');
for k = 1:M
    text(real(symgray(k)) - 0.0,imag(symgray(k)) + 0.3,...
        dec2base(x(k),2,4));
     text(real(symgray(k)) - 0.5,imag(symgray(k)) + 0.3,...
         num2str(x(k)));
    
    text(real(symbin(k)) - 0.0,imag(symbin(k)) - 0.3,...
        dec2base(x(k),2,4),'Color',[1 0 0]);
    text(real(symbin(k)) - 0.5,imag(symbin(k)) - 0.3,...
        num2str(x(k)),'Color',[1 0 0]);
end
title('16-QAM Symbol Mapping')
axis([-4 4 -4 4])
% 2、 |对比加入脉冲成型滤波器后链路的性能|
% |1) 仿真框图|
% 
% 
% 
% 
% 
% |加入脉冲成型滤波器|
% 
% 
% 
% |2) 参数设置|
%% 
% # |QAM 16|
% # |300000bits|
% # |10dB高斯白噪声|
% # |采样频率 4|
% # |4bit每个symbol|
%% 
% |3) 基本步骤|
% 生成信号


M = 16; % Modulation order
k = log2(M); % Number of bits per symbol
numBits = 300000; % Number of bits to process
sps = 4; % Number of samples per symbol (oversampling factor)

% 创建RRC滤波器


filtlen = 10; % Filter length in symbols
rolloff = 0.25; % Filter rolloff factor

rrcFilter = rcosdesign(rolloff,filtlen,sps);

fvtool(rrcFilter,'Analysis','Impulse');
% 计算系统BER

rng default; % Use default random number generator
dataIn = randi([0 1],numBits,1); % Generate vector of binary data
dataInMatrix = reshape(dataIn,length(dataIn)/k,k); % Reshape data into binary 4-tuples
dataSymbolsIn = bi2de(dataInMatrix); % Convert to integers
dataMod = qammod(dataSymbolsIn,M);
txFiltSignal = upfirdn(dataMod,rrcFilter,sps,1);
EbNo = 10;
snr = EbNo + 10*log10(k) - 10*log10(sps);
rxSignal = awgn(txFiltSignal,snr,'measured');
rxFiltSignal = upfirdn(rxSignal,rrcFilter,1,sps); % Downsample and filter
rxFiltSignal = rxFiltSignal(filtlen + 1:end - filtlen); % Account for delay
dataSymbolsOut = qamdemod(rxFiltSignal,M);
dataOutMatrix = de2bi(dataSymbolsOut,k);
dataOut = dataOutMatrix(:); % Return data in column vector
[numErrors,ber] = biterr(dataIn,dataOut);
fprintf('\nFor an EbNo setting of %3.1f dB, the bit error rate is %5.2e, based on %d errors.\n', ...
    EbNo,ber,numErrors)
% 可视化滤波器效果

EbNo = 20;
snr = EbNo + 10*log10(k) - 10*log10(sps);
rxSignal = awgn(txFiltSignal,snr,'measured');
rxFiltSignal = upfirdn(rxSignal,rrcFilter,1,sps); % Downsample and filter
rxFiltSignal = rxFiltSignal(filtlen + 1:end - filtlen); % Account for delay
eyediagram(txFiltSignal(1:2000),sps*2);
eyediagram(rxSignal(1:2000),sps*2);
eyediagram(rxFiltSignal(1:2000),2);
% 画星图


scatplot = scatterplot(sqrt(sps)*...
    rxSignal(1:sps*5e3),...
    sps,0,'g.');
hold on;
scatterplot(rxFiltSignal(1:5e3),1,0,'kx',scatplot);
title('Received Signal, Before and After Filtering');
legend('Before Filtering','After Filtering');
axis([-5 5 -5 5]); % Set axis ranges
hold off;
% 3、对比加入脉冲成型滤波器和卷积码进行纠错后链路的性能
% |1) 仿真框图|
% 
% 
% 
% 
% 
% |16-QAM调制的基带数字通信系统通过高斯白噪声信道|
% 
% 
% 
% |2) 参数设置|
%% 
% # |QAM 16|
% # |30000bits|
% # |10dB高斯白噪声|
%% 
% |3) 基本步骤|
% 初始化

M = 16; % Modulation order
k = log2(M); % Number of bits per symbol
numBits = 1e6; % Number of bits to process
sps = 4; % Number of samples per symbol (oversampling factor)
filtlen = 10; % Filter length in symbols
rolloff = 0.25; % Filter rolloff factor
rng default;                     % Use default random number generator
dataIn = randi([0 1],numBits,1); % Generate vector of binary data

% 进行卷积编码

constrlen = [5 4]; % Code constraint length
genpoly = [23 35 0; 0 5 13] % Generator polynomials
tPoly = poly2trellis(constrlen,genpoly);
codeRate = 2/3;
dataEnc = convenc(dataIn,tPoly);


% 调制


dataEncMatrix = reshape(dataEnc, ...
    length(dataEnc)/k,k); % Reshape data into binary 4-tuples
dataSymbolsIn = bi2de(dataEncMatrix); % Convert to integers
dataMod = qammod(dataSymbolsIn,M);
% RRC(Root-Raising-Cosine Filter)滤波

rrcFilter = rcosdesign(rolloff,filtlen,sps);
txSignal = upfirdn(dataMod,rrcFilter,sps,1);

% 加入高斯噪声

EbNo = 10;
snr = EbNo+10*log10(k*codeRate)-10*log10(sps);
rxSignal = awgn(txSignal,snr,'measured');

% 解调

rxFiltSignal = upfirdn(rxSignal,rrcFilter,1,sps); % Downsample and filter
rxFiltSignal = rxFiltSignal(filtlen + 1:end - filtlen); % Account for delay
dataSymbolsOut = qamdemod(rxFiltSignal,M);

% 解码

dataOutMatrix = de2bi(dataSymbolsOut,k);
codedDataOut = dataOutMatrix(:); % Return data in column vector
traceBack = 16; % Traceback length for decoding
numCodeWords = floor(length(codedDataOut)*2/3); % Number of complete codewords
dataOut = vitdec(codedDataOut(1:numCodeWords*3/2), ...
           tPoly,traceBack,'cont','hard'); % Decode data
% 计算误比特率

decDelay = 2*traceBack; % Decoder delay, in bits
[numErrors,ber] = ...
   biterr(dataIn(1:end - decDelay),dataOut(decDelay + 1:end));       
fprintf('\nThe bit error rate is %5.2e, based on %d errors.\n', ...
    ber,numErrors)
%% 四、实验结果与分析
% |通过性能对比可以看出，升余弦滤波器可以有效减少16-QAM数字通信系统的误码率，改变编码方式也可以改进误码率。|
##### SOURCE END #####
--></body></html>